package com.ktgj.customer.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.common.security.annotation.PreAuthorize;
import com.ktgj.customer.domain.EmployeeReturnvisit;
import com.ktgj.customer.service.IEmployeeReturnvisitService;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * VIP资源回访记录Controller
 * 
 * @author ruoyi
 * @date 2022-09-20
 */
@RestController
@RequestMapping("/returnvisit")
public class EmployeeReturnvisitController extends BaseController
{
    @Autowired
    private IEmployeeReturnvisitService employeeReturnvisitService;

    /**
     * 查询VIP资源回访记录列表
     */
//    @PreAuthorize(hasPermi = "customer:returnvisit:list")
    @PostMapping("/list")
    public TableDataInfo list(@RequestBody EmployeeReturnvisit employeeReturnvisit)
    {
        startPage();
        List<EmployeeReturnvisit> list = employeeReturnvisitService.selectEmployeeReturnvisitList(employeeReturnvisit);
        return getDataTable(list);
    }

    /**
     * 导出VIP资源回访记录列表
     */
    @PreAuthorize(hasPermi = "customer:returnvisit:export")
    @Log(title = "VIP资源回访记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EmployeeReturnvisit employeeReturnvisit) throws IOException
    {
        List<EmployeeReturnvisit> list = employeeReturnvisitService.selectEmployeeReturnvisitList(employeeReturnvisit);
        ExcelUtil<EmployeeReturnvisit> util = new ExcelUtil<EmployeeReturnvisit>(EmployeeReturnvisit.class);
        util.exportExcel(response, list, "VIP资源回访记录数据");
    }

    /**
     * 获取VIP资源回访记录详细信息
     */
    @PreAuthorize(hasPermi = "customer:returnvisit:query")
    @GetMapping(value = "/{returnVisitId}")
    public AjaxResult getInfo(@PathVariable("returnVisitId") Long returnVisitId)
    {
        return AjaxResult.success(employeeReturnvisitService.selectEmployeeReturnvisitById(returnVisitId));
    }

    /**
     * 新增VIP资源回访记录
     */
//    @PreAuthorize(hasPermi = "customer:returnvisit:add")
//    @Log(title = "VIP资源回访记录", businessType = BusinessType.INSERT)
    @PostMapping("/addVisit")
    public AjaxResult addVisit(@RequestBody EmployeeReturnvisit employeeReturnvisit)
    {
        return toAjax(employeeReturnvisitService.insertEmployeeReturnvisit(employeeReturnvisit));
    }

    /**
     * 修改VIP资源回访记录
     */
    @PreAuthorize(hasPermi = "customer:returnvisit:edit")
    @Log(title = "VIP资源回访记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EmployeeReturnvisit employeeReturnvisit)
    {
        return toAjax(employeeReturnvisitService.updateEmployeeReturnvisit(employeeReturnvisit));
    }

    /**
     * 删除VIP资源回访记录
     */
    @PreAuthorize(hasPermi = "customer:returnvisit:remove")
    @Log(title = "VIP资源回访记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{returnVisitIds}")
    public AjaxResult remove(@PathVariable Long[] returnVisitIds)
    {
        return toAjax(employeeReturnvisitService.deleteEmployeeReturnvisitByIds(returnVisitIds));
    }
}
